{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4969768f",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "#导入库\n",
    "import psutil\n",
    "import time \n",
    "\n",
    "\n",
    "#代码\n",
    "for i in range(10):\n",
    "    cpu = psutil.cpu_percent()\n",
    "    mem = psutil.virtual_memory()\n",
    "    print(cpu,mem[2])\n",
    "    time.sleep(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67ff9623",
   "metadata": {},
   "source": [
    "浏览器 => 服务器\n",
    "     <= 返回"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "580b3b9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入库\n",
    "import requests as r\n",
    "\n",
    "#代码\n",
    "info = {\"user\":\"bobby\",\"pwd\":\"666666\"} \n",
    "data = r.get(\"http://news.baidu.com\".params=info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e56150d",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "#导入库\n",
    "import psutil,time\n",
    "import requests as r\n",
    "\n",
    "#发送数据\n",
    "for i in range(10):\n",
    "    cpu = psutil.cpu_percent()\n",
    "    mem = psutil.virtual_memory()\n",
    "    info = {\"cpu\":cpu,\"mem\":mem[2]}\n",
    "    resp = r.get(\"http://127.0.0.1:5000\",params=info)\n",
    "    print(resp.url)\n",
    "    time.sleep(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f9345ece",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "vscode": {
   "interpreter": {
    "hash": "c3bd44260b24975a52c0b6e3efc83d7e83b0017dee8c9f9cd5ef0c9b3940f46d"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
